/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package example;
import facecat.topin.core.*;
import facecat.topin.xml.*;
import facecat.topin.tab.*;
import facecat.topin.btn.*;
import facecat.topin.swing.*;
import org.w3c.dom.Node;

/*
* 按钮示例
*/
public class ButtonExample extends FCUIXml implements FCTouchEventCallBack
{
    /*
    * 加载Xml
    * @param fileName 文件名
    * @param view 视图名称
    */
   public void loadXml(String fileName, FCView view)
   {
       setScript(new FaceCatScript(this));
       super.loadXml(fileName, view);
       //获取第二页
       FCTabPage tabPage = getTabPage("TabPage2");
       FCButton button = new FCButton();
       button.setLocation(new FCPoint(100, 100));
       button.setSize(new FCSize(100, 20));
       tabPage.addView(button);
       button.setText("确定");

       //从Xml中获取按钮
       FCButton button1 = getButton("Button");
       FCButton button2 = getButton("Button2");
       FCButton button3 = getButton("Button3");
       FCButton button4 = getButton("Button4");

       //绑定事件
       button1.addEvent(this, FCEventID.Click, this);
       button2.addEvent(this, FCEventID.Click, this);
       button3.addEvent(this, FCEventID.Click, this);
       button4.addEvent(this, FCEventID.Click, this);
       button.addEvent(this, FCEventID.Click, this);
   }
   
   /*
   * 创建视图
   * @param node 节点
    * @param type 类型
   */
    public FCView createView(Node node, String type)
    {
        if (type.equals("mybutton"))
        {
            return new MyButton();
        }
        return super.createView(node, type);
    }
    
    /*
    * 点击事件
    * @param eventName 事件ID
    * @param sender 发送者
    * @param touchInfo 触摸信息
    * @param invoke 引用者
    */
    public void callTouchEvent(String eventName, Object sender, FCTouchInfo touchInfo, Object invoke)
    {
        FCButton button = (FCButton)sender;
    }
}